package com.jiangyao.controller;

import com.jiangyao.common.ApiResult;
import com.jiangyao.model.dto.backend.EvaluationDTO;
import com.jiangyao.model.dto.backend.EvaluationListPageDTO;
import com.jiangyao.model.vo.backend.EvaluationListVO;
import com.jiangyao.service.EvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 评价 controller
 *
 * @author: yangyongchuan
 * @create: 2020年09月05日 13:26
 */
@RestController
@RequestMapping("/evaluation")
@Api(tags = "评价管理")
public class EvaluationController extends BaseController {

	@Autowired
	private EvaluationService evaluationService;

	/**
	 * 获取评价列表
	 *
	 * @param listPageDTO 列表DTO
	 * @return 结果
	 */
	@ApiOperation(value = "获取评价列表")
	@PostMapping("/list")
	public ApiResult<EvaluationListVO> getListPage(@Validated({EvaluationListPageDTO.ListPage.class}) @RequestBody EvaluationListPageDTO listPageDTO) {
		return ApiResult.success(evaluationService.getListPage(listPageDTO));
	}

	/**
	 * 获取回复评价列表
	 *
	 * @param listPageDTO 回复评价列表DTO
	 * @return 结果
	 */
	@ApiOperation(value = "获取回复评价列表", notes = "必填字段：releteId")
	@PostMapping("/reply/list")
	public ApiResult<EvaluationListVO> getReplyListPage(@Validated({EvaluationListPageDTO.Detail.class}) @RequestBody EvaluationListPageDTO listPageDTO) {
		return ApiResult.success(evaluationService.getReplyListPage(listPageDTO));
	}

	/**
	 * 回复评价
	 *
	 * @param replyDTO 回复评价DTO
	 * @return 结果
	 */
	@ApiOperation(value = "回复评价")
	@PostMapping("/reply")
	public ApiResult<String> reply(@Validated({EvaluationDTO.reply.class}) @RequestBody EvaluationDTO replyDTO) {
		evaluationService.reply(replyDTO);
		return new ApiResult<>();
	}

	/**
	 * 编辑审核状态
	 *
	 * @param editDTO 审核DTO
	 * @return 结果
	 */
	@ApiOperation(value = "编辑审核状态", notes = "必填字段：idList,status")
	@PostMapping("/editStatus")
	public ApiResult<String> editStatus(@Validated({EvaluationDTO.Edit.class}) @RequestBody EvaluationDTO editDTO) {
		evaluationService.editStatus(editDTO);
		return new ApiResult<>("ok");
	}


}
